package au.com.uptick.serendipity.client.view;

import au.com.uptick.serendipity.client.presenter.ErrorDialogPresenterWidget;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.PopupViewImpl;

public class ErrorDialogPopupView extends PopupViewImpl implements ErrorDialogPresenterWidget.MyView {

    interface ErrorDialogPopupViewUiBinder extends UiBinder<PopupPanel, ErrorDialogPopupView> {
    }

    private static ErrorDialogPopupViewUiBinder uiBinder = GWT.create(ErrorDialogPopupViewUiBinder.class);

    @UiField
    Button okButton;

    private final PopupPanel widget;

    @Inject
    public ErrorDialogPopupView(EventBus eventBus) {
        super(eventBus);
        widget = uiBinder.createAndBindUi(this);
    }

    @Override
    public Widget asWidget() {
        return widget;
    }

    @UiHandler("okButton")
    void okButtonClicked(ClickEvent event) {
        widget.hide();
    }
}
